<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let obj = {
            name:"张三",
            age:10
        }
//		generator函数
        function* objectEntries(obj){
			//获取对象所有的key保存到数组[name,age]
			const propkeys = Object.keys(obj);
                   
//		迭代器一旦生成我们就可以利用for of进行遍历了
		// for(let [key,val] of objectEntries(obj)){
		// 	console.log(key,val)
		// }
			for(const propkey of propkeys){
				yield [propkey,obj[propkey]];
				
			}
        }

        let it = objectEntries(obj)
        console.log(it.next());
        console.log(it.next());
        console.log(it.next());
        
    </script>
</body>
</html>